package cn.cdzdjd.controller;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import cn.cdzdjd.dao.DictMapper;
import cn.cdzdjd.entity.Dict;
import cn.cdzdjd.util.Result;
import cn.cdzdjd.vo.DictVo;

@RestController
@RequestMapping("/api/dict")
public class DictController {
	@Resource
	private DictMapper dictMapper;
	
	
	@GetMapping("/notice")
	public Result<?> getNotice(){
		LambdaQueryWrapper<Dict> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(Dict::getCode, "notice");
		List<Dict> list = dictMapper.selectList(queryWrapper);
		List<DictVo> dictvoList = new ArrayList<>();
		list.forEach(item->{
			DictVo dictVo = new DictVo();
			BeanUtils.copyProperties(item, dictVo);
			dictvoList.add(dictVo);
		});
		return new Result<>().ok(dictvoList);
		
	}
}
